package com.wh.controller.outstorehouse;

import com.wh.pojo.Picking;
import com.wh.service.outstorehouse.PickingService;
import com.wh.vo.PageResult;
import com.wh.vo.PickingUser;
import com.wh.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/picking/")
public class PickingController {

    @Autowired
    private PickingService pickingService;

    @GetMapping("getOptions")
    public SysResult getOptions(){
        List<String> outStorehouseIdList = pickingService.getOptions();
        return SysResult.success(outStorehouseIdList);
    }

    @PutMapping("picking")
    public SysResult picking(@RequestBody PickingUser pickingUser){
        pickingService.picking(pickingUser.getOutStorehouseId(),pickingUser.getUser());
        return SysResult.success();
    }

    @GetMapping("list")
    public SysResult getPickingList(PageResult pageResult){
        pageResult = pickingService.getPickingList(pageResult);
        return SysResult.success(pageResult);
    }

    @PutMapping("finish")
    public SysResult finish(@RequestBody Picking picking){
        pickingService.finish(picking);
        return SysResult.success();
    }


}
